﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using AOP.Filter.Result;
using Microsoft.AspNetCore.Mvc;
using SERVICE.Admin.IService;

namespace Admin.Controllers.System
{
    [Description("系统设置")]
    public class RuleController : Controller
    {
        ISyetemService syetemService;
        public RuleController(ISyetemService syetemService)
        {
            this.syetemService = syetemService;
        }
        [Description("角色列表"), Native]
        public IActionResult Index()
        {
            return View();
        }
        [Description("角色列表"), HttpGet]
        public object GetRule()
        {
            return syetemService.GetRules().AsParallel().Select(x => new { x.id, x.name, time = Common.Standard.TimeHelper.SecondStampToTime(x.createdtime).ToString("yyyy-MM-dd HH:mm:ss"), actionNames = x.SystemJurisdictions.Select(c => c.name) });
        }
        [Description("删除角色"), HttpPost]
        public bool Del(int id)
        {
            return syetemService.DelRule(id);
        }
    }
}